package com.sky.Protocol;

import io.netty.buffer.ByteBuf;

/**
 * Created by sun on 2017-06-16.
 */
public class MessageFactory {
    private int packId;

    public MessageFactory() {
        packId = 0;
    }

    public MessageProtocol createMessage(int mstType,String content) {
        return createMessage(1,mstType,0,content);
    }

    public MessageProtocol createMessage(int version,int mstType,int tag,String content) {
        MessageProtocol msg = new MessageProtocol();
        packId++;

        MessageHeader header = new MessageHeader();

        header.setVersion(version);
        header.setMsgType(mstType);
        header.setTag(tag);
        header.setPackId(packId);

        msg.setHeader(header);
        msg.setBody(content);

        return msg;
    }
}
